package com.example.endproject;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBHelper extends SQLiteOpenHelper {
    public static String DB_NAME = "Login_Registration";
    public static int VERSION = 1;
    public static String TB_NAME_USER = "Login";
    public static String TB_NAME_MSG = "Msg";
    public static String TB_NAME_Relate = "Relate";
    public DBHelper(@Nullable Context context) {
        super(context, DB_NAME, null, VERSION);
    }
//    学号ID，姓名Name，年龄Age，专业Department，爱好Hobby，星座Constellation，个性签名Signature
    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql_User = "create table "+TB_NAME_USER+" (user_name TEXT PRIMARY KEY,pwd TEXT)";
        String sql_MSG = "create table "+TB_NAME_MSG+
                "(ID TEXT PRIMARY KEY," +
                "name TEXT," +
                "age INTEGER," +
                "department TEXT," +
                "hobby TEXT," +
                "constellation TEXT," +
                "signature TEXT)";
        String sql_Relate = "create table "+TB_NAME_Relate+" (user_name TEXT PRIMARY KEY,ID TEXT)";
        String init01 = "insert into "+TB_NAME_USER+" values('1000','1000')";
        String init02 = "insert into "+TB_NAME_MSG+" values('41810063','詹友鹏','21','计算机','打球','水瓶','从哪跌倒在哪躺一会')";
        String init03 = "insert into "+TB_NAME_Relate+" values('41810063','1000')";
        db.execSQL(sql_MSG);
        db.execSQL(sql_User);
        db.execSQL(sql_Relate);
        db.execSQL(init01);
        db.execSQL(init02);
        db.execSQL(init03);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
